package stu.day25_day32.day25.all;

public class LeetCode111 {
    public int minDepth(TreeNode root) {
        if(root == null){
            return 0;
        }
        if(root.left==null && root.right==null){
            return 1;
        }

        int l = minDepth(root.left);
        int r = minDepth(root.right);

        if(root.right==null){
            return l+1;
        }
        if(root.left==null){
            return r+1;
        }


        int h = Math.min(l,r);

        return h+1;

    }
}
